<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page   import="com.bbdjt.weixin.util.SubsystemIp"%>
<%@ include file="/inc/css.inc"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>患者入组</title>
		<link rel="stylesheet" href="${css}/amazeui.css" />
		<link rel="stylesheet" href="${css}/validate.css" />
		<link rel="stylesheet" href="${css}/joy.css" />
		<link rel="stylesheet" href="${css}/publicstyle.css" />
		<script src="${js}/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="${js}/amazeui.min.js" type="text/javascript" charset="utf-8"></script>	
	</head>
	<body>
		<div>
			<form id="form1">
				<div class="questioncard">
					<div class="questiontitle">
						<span>1. 性别</span>
					</div>
					<div class="questionitem">
						<label class="am-radio">
					      <input type="radio" name="sex" value="1" data-am-ucheck data-required="true" data-descriptions="sex">
					      A：男
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="sex" value="0" data-am-ucheck data-required="true" data-descriptions="sex">
					      B：女
					    </label>
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>2. 年龄</span>
					</div>
					<div class="questionitem">
						<label class="am-radio">
					      <input type="radio" name="age" value="≤30岁" data-am-ucheck data-required="true" data-descriptions="age">
					      A：≤30岁
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="age" value="31-40岁" data-am-ucheck data-required="true" data-descriptions="age">
					      B：31-40岁
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="age" value="41-50岁" data-am-ucheck data-required="true" data-descriptions="age">
					      C：41-50岁
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="age" value="51-60岁" data-am-ucheck data-required="true" data-descriptions="age">
					      D：51-60岁
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="age" value="61-70岁" data-am-ucheck data-required="true" data-descriptions="age">
					      E：61-70岁
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="age" value="71-80岁" data-am-ucheck data-required="true" data-descriptions="age">
					      F：71-80岁
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="age" value="≥80岁" data-am-ucheck data-required="true" data-descriptions="age">
					      G：≥80岁
					    </label>
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>3. 糖尿病病程</span>
					</div>
					<div class="questionitem">
						<label class="am-radio">
					      <input type="radio" name="bingli" value="0-1年" data-am-ucheck data-required="true" data-descriptions="bingli">
					      A：0-1年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="bingli" value="1-3年" data-am-ucheck data-required="true" data-descriptions="bingli">
					     B：1-3年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="bingli" value="3-5年" data-am-ucheck data-required="true" data-descriptions="bingli">
					      C：3-5年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="bingli" value="5-10年" data-am-ucheck data-required="true" data-descriptions="bingli">
					      D：5-10年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="bingli" value=">10年" data-am-ucheck data-required="true" data-descriptions="bingli">
					      E：>10年
					    </label>
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>4. 口服药治疗时间</span>
					</div>
					<div class="questionitem">
						<label class="am-radio">
					      <input type="radio" name="therapyTime" value="0-1年" data-am-ucheck data-required="true" data-descriptions="therapytime">
					      A：0-1年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="therapyTime" value="1-3年" data-am-ucheck data-required="true" data-descriptions="therapytime">
					     B：1-3年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="therapyTime" value="3-5年" data-am-ucheck data-required="true" data-descriptions="therapytime">
					      C：3-5年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="therapyTime" value="5-10年" data-am-ucheck data-required="true" data-descriptions="therapytime">
					      D：5-10年
					    </label>
					    <label class="am-radio">
					      <input type="radio" name="therapyTime" value=">10年" data-am-ucheck data-required="true" data-descriptions="therapytime">
					      E：>10年
					    </label>
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>5. 当前治疗方案(多选)</span>
					</div>
					<div class="questionitem">
						<label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="诺和龙(瑞格列奈)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      A：诺和龙(瑞格列奈)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="达美康(格列齐特)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      B：达美康(格列齐特)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="亚莫利(格列美脲)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      C：亚莫利(格列美脲)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="格华止(二甲双胍)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      D：格华止(二甲双胍)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="拜唐苹(阿卡波糖)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      E：拜唐苹(阿卡波糖)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="文迪雅(罗格列酮)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      F：文迪雅(罗格列酮)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="艾可拓(吡格列酮)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      G：艾可拓(吡格列酮)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="捷诺维(西格列汀)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      H：捷诺维(西格列汀)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="安立泽(沙格列汀)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      I：安立泽(沙格列汀)
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="treatmentPlan" value="佳维乐(维格列汀)" data-am-ucheck data-required="true" data-descriptions="treatmentplan">
					      J：佳维乐(维格列汀)
					    </label>
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>6. 最关注的问题有哪些(多选)</span>
					</div>
					<div class="questionitem">
						<label class="am-radio">
					      <input type="checkbox" name="concernProblem" value="如何预防糖尿病" data-am-ucheck data-required="true" data-descriptions="concernproblem">
					      A：如何预防糖尿病
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="concernProblem" value="如何健康饮食" data-am-ucheck data-required="true" data-descriptions="concernproblem">
					      B：如何健康饮食
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="concernProblem" value="如何运动最安全有效" data-am-ucheck data-required="true" data-descriptions="concernproblem">
					      C：如何运动最安全有效
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="concernProblem" value="如何选用最适合的降糖药" data-am-ucheck data-required="true" data-descriptions="concernproblem">
					      D：如何选用最适合的降糖药
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="concernProblem" value="如何处理不良反应" data-am-ucheck data-required="true" data-descriptions="concernproblem">
					      E：如何处理不良反应
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="concernProblem" value="如何预防、识别和处理低血糖" data-am-ucheck data-required="true" data-descriptions="concernproblem">
					      F：如何预防、识别和处理低血糖
					    </label>
					    <label class="am-radio">
					      <input type="checkbox" name="concernProblem" value="如何监测血糖最有效" data-am-ucheck data-required="true" data-descriptions="concernproblem">
					      G：如何监测血糖最有效
					    </label>					    
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>空腹血糖(mmol/L)</span>
					</div>
					<div class="questionitem">
						<input class="am-form-field am-input-sm" type="text" name="fastingBloodGlucose" data-validate="fastingbloodglucose" data-describedby="fastingbloodglucose-description" placeholder="">
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>餐后血糖(mmol/L)</span>
					</div>
					<div class="questionitem">
						<input class="am-form-field am-input-sm" type="text" name="postprandialBloodGlucose" data-validate="postprandialbloodglucose" data-describedby="postprandialbloodglucose-description" placeholder="">
					</div>
				</div>
				<div class="questioncard">
					<div class="questiontitle">
						<span>请输入您的手机号</span>
					</div>
					<div class="questionitem">
						<input class="am-form-field am-input-sm" type="text" name="mobile" data-validate="mobile" data-describedby="mobile-description" placeholder="">
					</div>
				</div>
				<div class="questioncard b-margin">
					<div class="questiontitle">
						<span>请输入医生码</span>
					</div>
					<div class="questionitem">
						<input class="am-form-field am-input-sm" type="text" name="doctorCode" data-validate="doctorcode" data-describedby="doctorcode-description" placeholder="">
					</div>
				</div>
				<div class="btnbox">
					<button id="register" type="submit" class="am-btn am-btn-primary am-radius" value="${basePath}addPatient.action">提交</button>
				</div>
			</form>
		</div>
		<script type="text/javascript" src="${js}/jquery-mvalidate.js" ></script>
		<script>
			$.mvalidateExtend({
            fastingbloodglucose:{
                required : true,   
                pattern : /^([0-9](\.\d)?|0\d(\.\d)?|1\d(\.\d)?|2\d(\.\d)?|3[0-2](\.\d)?|33(\.[0-3])?)$/,
                each:function(){
                   
                },
                descriptions:{
                    required : '<div class="field-invalidmsg">请输入空腹血糖指数</div>',
                    pattern : '<div class="field-invalidmsg">您输入的格式不正确<br>范围是0-33.3的数字</div>'
                }
            },
            postprandialbloodglucose:{
            	required : true,   
                pattern : /^([0-9](\.\d)?|0\d(\.\d)?|1\d(\.\d)?|2\d(\.\d)?|3[0-2](\.\d)?|33(\.[0-3])?)$/,
                each:function(){
                   
                },
                descriptions:{
                    required : '<div class="field-invalidmsg">请输入餐后血糖指数</div>',
                    pattern : '<div class="field-invalidmsg">您输入的格式不正确<br>范围是0-33.3的数字</div>'
                }
            },
            mobile:{
            	required : true,   
                pattern : /^0?1[3|4|5|7|8][0-9]\d{8}$/,
                each:function(){
                   
                },
                descriptions:{
                    required : '<div class="field-invalidmsg">请输入您的手机号码</div>',
                    pattern : '<div class="field-invalidmsg">您输入的手机号码格式不正确</div>'
                }
            },
            doctorcode:{
            	required : true,   
                pattern : /^\d{4}$/,
                each:function(){
                   
                },
                descriptions:{
                    required : '<div class="field-invalidmsg">请输入4位数字医生码</div>',
                    pattern : '<div class="field-invalidmsg">您输入医生码不正确</div>'
                }
            }
        });
			$("#form1").mvalidate({
            type:1,
            onKeyup:true,
            sendForm:true,
            firstInvalidFocus:false,
            valid:function(event,options){
                //点击提交按钮时,表单通过验证触发函数
                 ajaxPost();
                 event.preventDefault();
            },
            invalid:function(event, status, options){
                //点击提交按钮时,表单未通过验证触发函数
                console.log("sdfds")
            },
            eachField:function(event,status,options){
                //点击提交按钮时,表单每个输入域触发这个函数 this 执向当前表单输入域，是jquery对象
            },
            eachValidField:function(val){},
            eachInvalidField:function(event, status, options){},
            conditional:{               
            },
            descriptions:{
                sex:{
                    required : '请选择性别'
                },
                bingli:{
                    required : '请选择病程'
                },
                age : {
                    required : '请选择年龄段',
                },
                therapytime:{
                    required : '请选择治疗时间'
                },
                treatmentplan:{
                    required : '请选择治疗方案'
                },
                concernproblem:{
                    required : '请选择您关注的问题'
                }
            }
        });
        
        function ajaxPost() {
			var url ="<%=basePath%>addPatient.action";
			var data = $("#form1").serialize();
			var result = jQuery.parseJSON(ajax(url, data));
			switch(result.type)
			{
				case 200:
					var id = result.content.id;
					localStorage.patientid = result.content.id;
					var url = window.location.href;
					var action = url.substring(url.lastIndexOf('=')+1, url.length);
					var arr = [id, action];
					setTimeout(function() {
					window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=<%=SubsystemIp.getInstance().getValue("yjb.AppID")%>&redirect_uri=http%3A%2F%2F<%=SubsystemIp.getInstance().getValue("bbdjt.port")%>%2Fadd_weixin.action&response_type=code&scope=snsapi_userinfo&state="
					+ arr + "#wechat_redirect";
				}, 1000);
			}
		}
		</script>
	</body>
</html>
